package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account  string `gorm:"type:varchar(20);not null;comment:'账号'"`
	Password string `gorm:"type:char(32);not null;comment:'密码'"`
	Mobile   string `gorm:"type:char(11);not null;comment:'手机号'"`
}

type Shop struct {
	gorm.Model
	Name  string  `gorm:"type:varchar(20);not null;comment:'商品名称'"`
	Price float64 `gorm:"type:decimal(10,2);not null;comment:'商品价格'"`
	Stock int     `gorm:"type:int;not null;comment:'商品库存'"`
	Img   string  `gorm:"type:varchar(200);not null;comment:'商品图片'"`
}

func (s *Shop) GetShopById(id int) error {
	return DB.Debug().Where("id = ?", id).Limit(1).Find(&s).Error
}
